package com.lykj.llw.box.custom.db

import android.content.Context
import android.database.sqlite.SQLiteDatabase
import android.database.sqlite.SQLiteOpenHelper

/**
 * 数据库辅助工具类
 */
class DBHelper(
    context: Context?, name: String?, factory: SQLiteDatabase.CursorFactory?,
    version: Int
) : SQLiteOpenHelper(context, name, null, version) {

    constructor(context: Context?) : this(context, "users.db", null, 1)

    override fun onCreate(db: SQLiteDatabase) {
        // 不存在创建用户表
        db.execSQL(
            "create table if not exists " + "user"
                    + "(_id integer primary key autoincrement,"
                    + "name" + " TEXT,"
                    + "pwd" + " TEXT)"
        )
    }

    override fun onUpgrade(db: SQLiteDatabase, oldVersion: Int, newVersion: Int) {}
}
